function PodeVirar () {
    var totaldepaginas = $('.pages');
    var $totalPg = parseInt(totaldepaginas.length)-1;
        if (PaginaAtual==$totalPg){
            $("#ico_setinhas_direita").fadeOut(300);
        } else if (PaginaAtual==0) {
            $("#ico_setinhas_esquerda").fadeOut(300);
            $("#ico_setinhas_direita").fadeIn(800);            
        } else {
            $("#ico_setinhas_esquerda").fadeIn(800);
            $("#ico_setinhas_direita").fadeIn(800);

        }
};

$(function () {
    $.mobile.hashListeningEnabled = false;
    $.mobile.pushStateEnabled = false;
    $(".menu div").click(function () {
        var pag = $(this).attr("id").replace("ico_pg", "#pagina");
        var rev = false;
        /*if (pag.replace("#pagina", "") < $.mobile.activePage.attr('id').replace("pagina", ""))
            rev = true;
        $.mobile.changePage(pag, { transition: 'slide', reverse: rev });*/
        if (pag.replace("#pagina", "") < $.mobile.activePage.attr('id').replace("pagina", ""))
            rev = true;
        $.mobile.changePage(pag, { transition: 'slide', reverse: rev });
    });

     $(".SetasPaginacao div").click(function () {
        if ($(this).attr("id")=="ico_setinhas_direita"){
            var pag = "#pagina"+(PaginaAtual+1).toString();
            var rev = false;
        } else {
            var pag = "#pagina"+(PaginaAtual-1).toString();
            var rev = true;

        }
        /*if (pag.replace("#pagina", "") < $.mobile.activePage.attr('id').replace("pagina", ""))
            rev = true;
        $.mobile.changePage(pag, { transition: 'slide', reverse: rev });*/
        $.mobile.changePage(pag, { transition: 'slide', reverse: rev });
    });
        

});
    


function playAudio(nome) {
    try {
        LED.playAudio(nome + ".mp3", myCallbackfunction);
    } catch (e) {
        $.each($("audio"), function (index, obj) {
            obj.pause();
        });
        var audio = document.getElementById(nome.replace(" ", ""));
        if (audio.currentTime != 0)
            audio.currentTime = 0;
        audio.play();
    }
}

function controlarSom() {
    var audio = document.getElementsByTagName('audio'),
               video = document.getElementsByTagName('video');
    for (a in audio) audio[a].volume = audio[a].volume == 1 ? 0 : 1;
    for (v in video) video[v].volume = video[v].volume == 1 ? 0 : 1;

    var nPosBotao = (audio[0].volume == 1 ? 0 : -$("#botaoSom" + sBotaoSomTamanho).width());
    $("#botaoSom" + sBotaoSomTamanho).css('background-position', nPosBotao);

}

function recarregarOED() {
    window.location.reload();
}

var isMobile = {
    Android: function () {
        return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function () {
        return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function () {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
    },
    Opera: function () {
        return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function () {
        return navigator.userAgent.match(/IEMobile/i);
    },
    any: function () {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};
var selected = "";
$("#ico_pg01").click(function(){
});

$("#ico_pg02").click(function(){
    //playAudio('audDireita');
});

$("#ico_pg03").click(function(){
    //playAudio('audDireita');
});

$("#ico_pg04").click(function(){
    //playAudio('audDireita');
});

$("#ico_pg05").click(function(){
    //playAudio('audDireita');
});

$("#ico_pg06").click(function(){
    //playAudio('audDireita');
});

$("#ico_pg07").click(function () {
    //playAudio('audDireita');

});
//var PaginaAtual = "";